# Looking for correlations (if any) in the term weights.
# There's not much excitement here...

term_weights_file <- 'one_to_1_d10_beta50000.term_weights'
filter_file <- 'actors.ids'

# Get the name of the matching from the term weights file.
matching <- sub('(.+)_d\\d+_beta\\d+.+', '\\1', term_weights_file, perl=TRUE)

if (filter_file != '') {
  filter <- read.table(filter_file)
  names(filter) <- c('term')
}

term_movies_file <- paste('big.',matching,'.new.links_by_movie',sep="")
term_movies_txt <- sub('(\\d+) (\\d+) (\\d+) .*', '\\1 \\2 \\3',
    readLines(term_movies_file), perl=TRUE)
term_movies = read.table(textConnection(term_movies_txt))
closeAllConnections()
names(term_movies) <- c('term','num_pages','num_movies')

term_ratings_file <- paste('big.',matching,'.new.term_ratings',sep="")
term_ratings <- read.table(term_ratings_file)
names(term_ratings) <- c('term','num_ratings')

term_weights <- read.table(term_weights_file)
names(term_weights) <- c('term','weight','num_coratings')

dat <- merge(term_movies,term_ratings,by='term')
dat <- merge(dat,term_weights,by='term')

if (filter_file != '') {
  dat <- merge(filter, dat)
}

summary(dat)
attach(dat)
plot(log(num_ratings), weight)

# Copyright (c) 2009 John Lees-Miller
# 
# Permission is hereby granted, free of charge, to any person
# obtaining a copy of this software and associated documentation
# files (the "Software"), to deal in the Software without
# restriction, including without limitation the rights to use,
# copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the
# Software is furnished to do so, subject to the following
# conditions:
# 
# The above copyright notice and this permission notice shall be
# included in all copies or substantial portions of the Software.
# 
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
# OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
# OTHER DEALINGS IN THE SOFTWARE.

